package org.jeecg.modules.meter.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.common.util.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class MeterEvidenceVO {

    private String sn;

    private String projectName;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy年MM月dd日")
    @DateTimeFormat(pattern="yyyy年MM月dd日")
    private Date payTime;

    private String customerName;

    private String floorName;

    private String roomName;

    private String beforeNum;

    private String nowNum;

    // 使用读数 nowNum-beforeNum 保留两位小数
    private String useNum;

    // 需要由分转化为元 保留两位小数
    private String payAmount;

    private Integer payMode;

    private String numToStr;
    private String officeAddress; // 管理处的地址
    private String officePhone; //管理处的电话
    private String createName; //收款人
    private String projectId; // 印章图片部分路径
    private String mustAmount;

    public String getUseNum(){
        BigDecimal beforeNumBig = BigDecimal.ZERO;
        if(StringUtils.isNotBlank(beforeNum)){
            beforeNumBig = new BigDecimal(beforeNum);
        }
        BigDecimal nowNumBig = BigDecimal.ZERO;
        if(StringUtils.isNotBlank(nowNum)){
            nowNumBig = new BigDecimal(nowNum);
        }
        return nowNumBig.subtract(beforeNumBig).setScale(2, BigDecimal.ROUND_HALF_DOWN).toString();
    }


    public String getPayModeStr(){
        String payModeStr = "";
        if(this.payMode != null){
            switch (this.payMode) {
                case 0:
                    payModeStr = "APP";
                    break;
                case 1:
                    payModeStr = "现金";
                    break;
                case 2:
                    payModeStr = "转账";
                    break;
                case 3:
                    payModeStr = "POS机";
                    break;
                case 4:
                    payModeStr = "微信";
                    break;
                case 5:
                    payModeStr = "支付宝";
                    break;
                case 6:
                    payModeStr = "银行划扣";
                    break;
                case 7:
                    payModeStr = "其他";
                    break;
                case 8:
                    payModeStr = "转冲";
                    break;
                default:
                    break;
            }
        }
        return payModeStr;
    }
}
